package com.ruoyi.material.util;


import com.ruoyi.common.utils.DateUtils;

import java.text.SimpleDateFormat;
import java.util.Date;

public class RandomlyGeneratedUtil {
    //获取当前时间+四位随机数，作为baseMaterial的id值
    public static String GeneratID(){
        String id;
        DateUtils.getNowDate();
        int code = (int)(Math.random()*(9999-1000+1))+1000;//产生1000-9999的随机数
//        id=;
//        id = "" + code;
        return DateUtils.getNowDate().toString()+code;

    }
    public static String GeneratID(String prefix, String name,String createBy){
        StringBuffer sb = new StringBuffer();
        sb.append(prefix);
        sb.append("-");
        sb.append(name);
        sb.append("-");
        sb.append(createBy);
        sb.append("-");
        SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd hh:mm:ss");
        sb.append(df.format(new Date()));
        int code = (int)(Math.random()*(9999-1000+1))+1000;
        sb.append("-"+code);
        return sb.toString();
    }

}
